library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

-- Word addressable ROM containing max 1024 words

entity ISMEM is
	Port (addr : in STD_LOGIC_VECTOR (9 downto 0);
			rdata : out STD_LOGIC_VECTOR (31 downto 0));
end ISMEM;

architecture syn of ISMEM is
	 
    type ROM_type is array (0 to 1023) of std_logic_vector (31 downto 0);

	 --------- BUFFERED WITH NOPS TO AVOID HAZARDS ---------
	 -- THESE PROGRAMS ARE MANUALLY BUFFERED WITH NOPS, SO THERE SHOULD BE NO HAZARDS
	
	 -- *** TEST <R Type> ***
	 -- load two immediates $9 and $8 using ORI, add them, and then store in $10, and then use SW to output to the world
	 -- signal ROM : ROM_TYPE := (x"34080002", x"34090003", x"00000000",x"00000000",x"00000000", x"01095021", x"00000000", x"00000000", x"00000000", x"00000000", x"ac0a0002", others => (others => '0'));
	 -- subtract.
	 -- signal ROM : ROM_TYPE := (x"34080012", x"34090003", x"00000000",x"00000000", x"01095023", x"00000000", x"00000000", x"ac0a0002", others => (others => '0'));
	 
	 -- SLT test
	 -- signal ROM : ROM_TYPE := (x"3418000A", x"3409000B",  x"00000000",x"00000000",x"0109502a", x"00000000",x"00000000", x"ac0a0002", others => (others => '0'));
	 --signal ROM : ROM_TYPE := (x"012a402a", others => (others => '0'));
	 
	 
	 -- test NOR and OR when free!
	 
	 -- *** BASIC storing and output to uart ***
	 -- load two immediates %10 using ORI, and then store in $10, and then use SW to output to the world
	 -- signal ROM : ROM_TYPE := (x"34080022", x"00000000",  x"00000000",x"ac080002", others => (others => '0'));
	 -- two loads into uart out back to back.
	 -- signal ROM : ROM_TYPE := (x"ac0a0002", x"ac0a0003", others => (others => '0'));
	 
	 -- *** LUI ***
	 -- loads into $8, and outputs via UART
	  -- signal ROM : ROM_TYPE := (x"3c080016", x"00000000",  x"00000000",x"ac080002", others => (others => '0'));
	 
	 -- *** STORE WORD ***
	 -- load value in to register, then store it into a word in data mem. Then, load it back into a register, and output to uart
	 -- signal ROM : ROM_TYPE := (x"34080002", x"00000000", x"00000000", x"00000000", x"3c011001", x"00000000", x"00000000", x"00000000", x"00200821", x"00000000", x"00000000", x"00000000", x"ac280000", x"00000000", x"00000000", x"00000000", x"3c011001", x"00000000", x"00000000", x"00000000", x"00200821", x"00000000", x"00000000", x"00000000", x"8c2a0000", x"00000000", x"00000000", x"00000000", x"ac0a0002", others => (others => '0'));
	 
	 -- BRANCH EQ
	 -- signal ROM : ROM_TYPE := (x"3408000f",x"3409000f",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"11090011",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"340b0005",x"00000000",x"00000000",x"ac0b0002",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002", others=>(others=>'0'));
	 -- branch upwards (earlier address)
	 --signal ROM : ROM_TYPE := (x"3408000f",x"3409000f",x"340a0001",x"00000000",x"00000000",x"00000000",x"014a5021",x"00000000",x"00000000",x"ac0a0002",x"00000000",x"00000000",x"00000000",x"00000000",x"1109fff4", others=>(others=>'0'));
	 
	 ---------- THE TRUE TEST. DATA, (NOT JUMP!) HAZARDS ALLOWED (dum dum dum dum)-----------
	 
	 --- Simple one : Register to register data hazards 
	 --- Add register containing 2 to register containing 3 (expect 5)
	 --- signal ROM : ROM_TYPE := (x"34080002", x"34090003", x"01285021", x"ac0a0002", others => (others => '0'));
	 
	 --- Simple two : Register keeps operating on itself. should give 6...12....24.... 3072
	 ---- expect 6, 12, 24, 48...768... etc
	 --- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"ac080002",x"20c60001",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff7",x"00000000",x"00000000",x"00000000",x"00000000", others => (others => '1'));
	 
    ----------- THE SECOND TRUE TEST. Load use data hazards -----------
	 --- Load use Hazard for LW, followed by SW
	 --- Should be solvable by pure forwarding, no stall
	 -- Expect 0xc
	 -- signal ROM : ROM_TYPE := (x"3c011001",x"3405000c",x"ac250000",x"8c260000", x"ac260004",x"8c230004",x"ac030002", others=>(others => '1'));
	 
	 --- Load use Hazard for LW, followed by some R-Type operation
	 --- Need stall
	 --- EXPECT 0xa
	 --- signal ROM : ROM_TYPE := (x"340e000f", x"3c011001",x"3410000a",x"ac300000",x"8c2f0000", x"01e07021",x"ac0e0002", others=>(others=>'0'));
	 		
	 ----------- THE THIRD TRUE TEST. Branch hazards -----------
	 -- Test after shifting to ID
	 -- signal ROM : ROM_TYPE := (x"3408000f",x"34090001",x"01285021",x"ac0a0002",x"34060000",x"3405000a",x"34080003",x"01084021",x"ac080002",x"20c60001",x"00000000",x"00000000",x"00000000",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff3",x"00000000",x"00000000",x"00000000",x"00000000", others => (others => '1'));
	 
	 -- Test stall from ID/EX
	 -- signal ROM : ROM_TYPE := (x"3408000f",x"34090001",x"01285021",x"ac0a0002",x"34060000",x"3405000a",x"34080003",x"01084021",x"ac080002",x"3c010000",x"34210001",x"00c13021",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff5",x"00000000",x"00000000",x"00000000",x"00000000", others => (others => '0'));
	 
	 -- Test WB -> ID read before write hazard, should be handled normally
	 -- Expecting result = 1e
	 -- signal ROM : ROM_TYPE := (x"3408000a", x"3409000b", x"00000000", x"00000000", x"00000000", x"00000000", x"3408000f", x"3409000f", x"00000000", x"00000000", x"11090009", x"01005021", x"00000000", x"00000000", x"ac0a0002", x"00000000", x"00000000", x"00000000", x"00000000", x"00000000", x"01095021", x"00000000", x"00000000", x"ac0a0002", others => (others => '0'));
	 
	 -- Test DM -> ID register hazard, should be handled by forwarding
	 -- Expecting result = 1e
	 -- signal ROM : ROM_TYPE := (x"3408000a",x"3409000b",x"00000000",x"00000000",x"00000000",x"00000000",x"3408000f",x"3409000f",x"00000000",x"11090009",x"01005021",x"00000000",x"00000000",x"ac0a0002",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"01095021",x"00000000",x"00000000", x"ac0a0002", others => (others => '0'));
	 
	 -- Test DM -> ID load hazard, should be handled by stall the instruction
	 -- Expecting result = 18
	 -- signal ROM : ROM_TYPE := (x"3408000a",x"3409000b",x"00000000",x"00000000",x"00000000",x"00000000",x"3c011001",x"3405000c",x"ac250000",x"3408000c",x"8c290000",x"00000000",x"11090009",x"01005021",x"00000000",x"00000000",x"ac0a0002",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"01095021",x"00000000",x"00000000",x"ac0a0002", others => (others => '0'));
	 
	 -- Test EX -> ID register hazard, should be handled by stall
	 -- Expecting result = 1e
	 -- signal ROM : ROM_TYPE := (x"3408000a",x"3409000b",x"00000000",x"00000000",x"00000000",x"00000000",x"3408000f",x"00000000",x"3409000f",x"11090009",x"01005021",x"00000000",x"00000000",x"ac0a0002",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"01095021",x"00000000",x"00000000",x"ac0a0002", others => (others => '0'));
	 
	 -- Test EX -> ID load hazard, should be handled by stall the instruction
	 -- Expecting result = 18
	 -- signal ROM : ROM_TYPE := (x"3408000a",x"3409000b",x"00000000",x"00000000",x"00000000",x"00000000",x"3c011001",x"3405000c",x"ac250000",x"3408000c",x"00000000",x"8c290000",x"11090009",x"01005021",x"00000000",x"00000000",x"ac0a0002",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"01095021",x"00000000",x"00000000",x"ac0a0002", others => (others => '0'));
	 
	 -- Test EX -> ID load hazard and DM -> ID register hazard happen together
	 -- Expecting result = 18
	 -- signal ROM : ROM_TYPE := (x"3408000a",x"3409000b",x"00000000",x"00000000",x"00000000",x"00000000",x"3c011001",x"3405000c",x"ac250000",x"3408000c",x"8c290000",x"11090009",x"01005021",x"00000000",x"00000000",x"ac0a0002",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"01095021",x"00000000",x"00000000",x"ac0a0002", others => (others => '0'));
	 
	 -- Test EX -> ID register hazard and DM -> ID load hazard happen together
	 -- Expecting result = 18
	  --signal ROM : ROM_TYPE := (x"3408000a",x"3409000b",x"00000000",x"00000000",x"00000000",x"00000000",x"3c011001",x"3405000c",x"ac250000",x"8c290000",x"3408000c",x"11090009",x"01005021",x"00000000",x"00000000",x"ac0a0002",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"01095021",x"00000000",x"00000000",x"ac0a0002", others => (others => '0'));
	 
	 --- TEST UART COMPATIBLE
	 -- SIMPLE WRITE TEST
	 -- signal ROM : ROM_TYPE := (x"340a00ff",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"ac0a0002", others => (others => '0'));
	 
	 -- Looparound TESTS
	 -- expect 30xx in dec
	 --signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"ac080002",x"20c60001",x"00000000",x"00000000",x"00000000",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff3",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffff", others => (others => '0'));
	 -- change to addu over addi
	 --signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"ac080002",x"3c010000",x"34210001",x"00c13021",x"00000000",x"00000000",x"00000000",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff1",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffff", others=>(others=>'0'));
	 -- expect 30xx in dec
	 -- MAIN
	 -- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"ac080002",x"3c010000",x"34210001",x"00c13021",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff5",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffff", others => (others => '0'));
	 -- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"3c010000",x"34210001",x"00c13021",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"1000fff6",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffff", others => (others=>'0'));
	 -- 2gap
	 -- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"ac080002",x"3c010000",x"34210001",x"00c13021",x"00000000",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff3",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffff", others=>(others=>'0'));
	 -- 3gap
	 --signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"ac080002",x"3c010000",x"34210001",x"00c13021",x"00000000",x"00000000",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff2",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffff", others=>(others=>'0'));
	 -- flowthrough, noloop, expect 6
	 -- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"ac080002",x"3c010000",x"34210001",x"00c13021",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffff", others=>(others=>'0'));
	-- 1gap (give 15..., only 9 times)
	--signal ROM : ROM_TYPE := (x"34060000",x"34050009",x"34080003",x"01084021",x"ac080002",x"3c010000",x"34210001",x"00c13021",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff4",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffff", others => (others=>'0'));
	
	---- EDGE TESTS
	-- 0 gap
	-- signal ROM : ROM_TYPE := (x"34080005",x"3409000a",x"01095021",x"ac0a0002", others=>(others=>'0'));
	-- 1 gap
	-- signal ROM : ROM_TYPE := (x"34080005",x"3409000a",x"01095021",x"00000000",x"ac0a0002", others=>(others=>'0'));
	-- 2 gap
	 --signal ROM : ROM_TYPE := (x"34080005",x"3409000a",x"01095021",x"00000000",x"00000000",x"ac0a0002", others=>(others=>'0'));
	-- gap3
		
	--	signal ROM : ROM_TYPE := (x"34080005",x"3409000a",x"01095020",x"00000000",x"00000000",x"00000000",x"ac0a0002", others=>(others=>'0'));
	 ---
	 
	 -- signal ROM : ROM_TYPE := (x"34080005",x"3409000a",x"00000000",x"01095021",x"00000000",x"00000000",x"00000000",x"ac0a0002", others=>(others=>'0'));
	 
	 -- signal ROM : ROM_TYPE := (x"ac000002",x"34080005",x"3409000a",x"340b000f",x"01095021",x"00000000",x"00000000",x"116afff8",x"ac0a0002", others=>(others=>'0'));
	 --signal ROM : ROM_TYPE := (x"ac000002",x"34080005",x"3409000a",x"340b000f",x"01095021",x"00000000",x"00000000",x"116afff8",x"ac0a0002",x"1000fffe", others=>(others=>'0'));
	 
	 
	 
	 --- RAGE TEST, expect 30...
	 --signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"3c010000",x"34210001",x"00c13021",x"00000000",x"00000000", x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"1000fff4",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"1000fffe", others => (others => '0'));
	 
	 -- sw nop nop
	 -- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"3c010000",x"34210001",x"00c13021",x"ac080002",x"00000000",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff3",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffff", others=>(others=>'0'));
	
	 -- no nop but sw acts like nop
	 -- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"3c010000",x"34210001",x"00c13021",x"ac080002",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff5",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffff", others => (others=>'0'));
	 
	 -- have nop
	 --signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"3c010000",x"34210001",x"00c13021",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff5",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"1000fffe", others=>(others=>'0'));
	 
	 -- no nop nor sw
	 -- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"01084021",x"3c010000",x"34210001",x"00c13021",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff6",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"1000fffe", others => (others=>'0'));
		
	 -- funny prob, nops added everywhere, 1 nop in betwee, should work
	 --signal ROM : ROM_TYPE :=  (x"34060000",x"3405000a",x"34080003",x"00000000",x"00000000",x"00000000",x"01084021",x"00000000",x"00000000",x"00000000",x"3c010000",x"34210001",x"00c13021",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffef",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"1000fffe",others=>(others=>'0'));
	 -- funny prob, nops added everyhwere, 2 nops in between, should give 6xxx
		-- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"00000000",x"00000000",x"00000000",x"01084021",x"00000000",x"00000000",x"00000000",x"3c010000",x"34210001",x"00c13021",x"00000000",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffee",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"1000fffe", others => (others=>'0'));
		-- funny prob, nops added everywhere, no nops in beween, should give 0
		--signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"00000000",x"00000000",x"00000000",x"01084021",x"00000000",x"00000000",x"00000000",x"3c010000",x"34210001",x"00c13021",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff0",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"1000fffe", others=>(others=>'0'));
		
		--signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"34190002",x"00000000",x"ac060002",x"00000000",x"00000000",x"00000000",x"01084021",x"00000000",x"00000000",x"00000000",x"3c010000",x"34210001",x"00c13021",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffee",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"1000fffe", others=>(others=>'0'));
		-- change to addu with integer
		-- number counter.
		-- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"34190002",x"34020001",x"00000000",x"ac060002",x"00000000",x"00000000",x"00000000",x"01084021",x"00000000",x"00000000",x"00000000",x"00c23021",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff0",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"1000fffe", others=>(others=>'0'));
		-- number counter one nop
		-- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"34020001",x"00000000",x"ac060002",x"00000000",x"00000000",x"00000000",x"01084021",x"00000000",x"00000000",x"00000000",x"00c23021",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffef",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"1000fffe", others=>(others=>'0'));
		
		
		-- RANDOM counter TEST, should work (with one nop)
		-- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"34020001",x"00000000",x"ac060002",x"00000000",x"00000000",x"00000000",x"01084021",x"00000000",x"00000000",x"00000000",x"00c23021",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000ffef",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"00000000",x"1000fffe", others=>(others=>'0'));
		
		-- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"34020001",x"00000000",x"ac060002",x"00000000",x"00000000",x"00000000",x"01084021",x"00000000",x"00000000",x"00000000",x"00c23021",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff0",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"00000000",x"1000fffe", others=>(others=>'0'));
		
		-- Good one
		--signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"34020001",x"00000000",x"ac060002",x"01084021",x"00c23021",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff5",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"1000fffe", others=>(others=>'0'));
				
		--==============================
		--ori $2, $0, 0xff
		--j here
		--here:
		--ori $2, $0, 0xee
		--sw $2, 2($0)
		--loopback:
		--j loopback
		-- Expect 0xff output, not oxee
		-- signal ROM : ROM_TYPE := (x"340200ff",x"08100003",x"340200ee",x"ac020002",x"08100004", others => (others=>'0'));
		
		
		
		
		--===================================
		-- Steven test1, expect 0xA
		--		# HALF-HALF case, Register file writes before reading
		--# Expect 0xa
		--
		--	ori $8, $0, 3
		--	ori $9, $0, 4
		--	nop
		--	nop
		--	nop
		--	addu $10, $8, $9 # $10 = 3 + 4 = 7
		--	nop
		--	nop
		--	addu $7, $10, $8 # $7 = 7 + 3 = 10
		--	nop
		--	nop
		--	sw $7, 2($0)
		-- signal ROM : ROM_TYPE := (x"34080003",x"34090004",x"00000000",x"00000000",x"00000000",x"01095021",x"00000000",x"00000000",x"01483821",x"00000000",x"00000000",x"ac070002", others => (others=>'0'));
		
		
		--================================
		--Steven test2
		--		# DM/WB -> EX forwarding
		--# Expect 0xa
		--
		--	ori $8, $0, 3
		--	ori $9, $0, 4
		--	nop
		--	nop
		--	nop
		--	addu $10, $8, $9 # $10 = 3 + 4 = 7
		--	nop
		--	addu $7, $10, $8 # $7 = 7 + 3 = 10
		--	nop
		--	nop
		--	sw $7, 2($0)
		-- signal ROM : ROM_TYPE := (x"34080003",x"34090004",x"00000000",x"00000000",x"00000000",x"01095021",x"00000000",x"01483821",x"00000000",x"00000000",x"ac070002", others=>(others=>'0'));
		
		--==================================
		-- Steven Test 3
		--		ori $8, $0, 3
		--	ori $9, $0, 4
		--	nop
		--	nop
		--	nop
		--	addu $10, $8, $9 # $10 = 3 + 4 = 7
		--	addu $7, $10, $8 # $7 = 7 + 3 = 10
		--	nop
		--	nop
		--	sw $7, 2($0)
		-- signal ROM : ROM_TYPE := (x"34080003",x"34090004",x"00000000",x"00000000",x"00000000",x"01095021",x"01483821",x"00000000",x"00000000",x"ac070002", others=>(others=>'0'));
		
		--==============================
		-- Steven Test 4(extreme)
		--		# both EX/DM -> EX and DM/WB -> EX, extreme case (refer to lec note)
		--# Expect 0xe
		--
		--	ori $8, $0, 3
		--	ori $9, $0, 4
		--	nop
		--	nop
		--	nop
		--	addu $10, $8, $9 # $10 = 4 + 3 = 7
		--	addu $10, $10, $9 # $10 = 7 + 4 = 11
		--	addu $7, $10, $8 # $7 = 11 + 3 = 14
		--	nop
		--	nop
		--	sw $7, 2($0)
		-- signal ROM : ROM_TYPE := (x"34080003",x"34090004",x"00000000",x"00000000",x"00000000",x"01095021",x"01495021",x"01483821",x"00000000",x"00000000",x"ac070002", others=>(others=>'0'));
		
		-- ==================
		-- Steven Test 5
		--		# load use, stall and DM/WB -> EX forwarding
		--# Expect 0x18
		--	
		--	lui $1, 0x00001001 # offset of data segment
		--
		--	ori $5, $0, 0xc
		--	sw $5, 0($1) # store some non-zero value in memory
		--	
		--	#### END OF SETUP ###
		--
		--	lw $8, 0($1)
		--	addu $9, $8, $8 # $9 = 12 + 12 = 24
		--	nop
		--	nop
		--	sw $9, 2($0)
		
		--signal ROM : ROM_TYPE := (x"3c011001",x"3405000c",x"ac250000",x"8c280000",x"01084821",x"00000000",x"00000000",x"ac090002", others=>(others=>'0'));
		
		-- ================
		-- Steven Test 6
		--# load use with extreme data hazard
		--# Expect 0x30
		--
		--	lui $1, 0x00001001 # offset of data segment
		--
		--	ori $5, $0, 0xc
		--	sw $5, 0($1) # store some non-zero value in memory
		--	
		--	#### END OF SETUP ###
		--
		--	lw $8, 0($1)
		--	addu $10, $8, $8 # $10 = 12 + 12 = 24
		--	addu $10, $10, $8 # $10 = 24 + 12 = 36
		--	addu $7, $10, $8 # $7 = 36 + 12 = 48
		--	nop
		--	nop
		--	sw $7, 2($0)
		-- signal ROM : ROM_TYPE := (x"3c011001",x"3405000c",x"ac250000",x"8c280000",x"01085021",x"01485021",x"01483821",x"00000000",x"00000000",x"ac070002", others=>(others=>'0'));
		
		-- ==================
		-- Steven Jump Test
		--		# unconditional jump
		--# Expect 0x15
		--
		--	ori $8, $0, 0xa
		--	ori $9, $0, 0xb
		--	nop
		--	nop
		--	addu $10, $8, $9
		--	j apple
		--	addu $10, $10, $10
		--	nop
		--	nop
		--pear: # WE DON'T WANT TO BE HERE
		--	addu $10, $8, $10
		--	nop
		--	nop
		--	sw $10, 2($0)
		--	j pear
		--	nop
		--apple:
		--	sw $10, 2($0)
		 --signal ROM : ROM_TYPE := (x"3408000a",x"3409000b",x"00000000",x"00000000",x"01095021",x"0810000f",x"014a5021",x"00000000",x"00000000",x"010a5021",x"00000000",x"00000000",x"ac0a0002",x"08100009",x"00000000",x"ac0a0002",x"0810000f", others=>(others=>'0'));
		-- ^ doesn't work. Adding nop before jmp
		-- signal ROM : ROM_TYPE := (x"3408000a",x"3409000b",x"00000000",x"00000000",x"01095021",x"00000000",x"08100010",x"014a5021",x"00000000",x"00000000",x"010a5021",x"00000000",x"00000000",x"ac0a0002",x"0810000a",x"00000000",x"ac0a0002", others=>(others=>'0'));
		-- Remove endless loop, but no nop
		-- signal ROM : ROM_TYPE := (x"3408000a",x"3409000b",x"00000000",x"00000000",x"01095021",x"0810000f",x"014a5021",x"00000000",x"00000000",x"010a5021",x"00000000",x"00000000",x"ac0a0002",x"08100009",x"00000000",x"ac0a0002", others=>(others=>'0'));
		
		--=====
		-- Steven test 7 (beast), expect 3bh, 59d
		-- signal ROM: ROM_TYPE := (x"3c011001",x"3408000d",x"ac280000",x"3408000c",x"ac280004",x"01085021",x"014a5021",x"01483821",x"ac270008",x"8c2a0004",x"8c270000",x"ac270004",x"8c270008",x"34e80001",x"00e8482a",x"00e84023",x"00ea5824",x"00eb5027",x"010a5023",x"01495023", x"ac0a0002", others=>(others=>'0'));
		-- signal ROM: ROM_TYPE := (x"3c011001",x"3408000d",x"ac280000",x"3408000c",x"ac280004",x"ac080002",x"01085021",x"014a5021",x"01483821",x"ac270008",x"ac070002",x"8c2a0004",x"8c270000",x"ac270004",x"ac070002",x"8c270008",x"34e80001",x"00e8482a",x"ac090002",x"ac070002",x"ac080002",x"00e84023",x"ac080002",x"00ea5824",x"ac0b0002",x"00eb5027",x"ac0a0002",x"010a5023",x"ac0a0002",x"01495023",x"ac0a0002", others=>(others=>'0'));
		 -- ^ Use this
		-- signal ROM: ROM_TYPE := (x"3c011001",x"3408000d",x"ac280000",x"3408000c",x"ac280004",x"ac080002",x"01085021",x"014a5021",x"01483821",x"ac270008",x"ac070002",x"8c2a0004",x"8c270000",x"ac270004",x"ac070002",x"8c270008",x"00000000",x"34e80001",x"00e8482a",x"ac090002",x"ac070002",x"ac080002",x"00e84023",x"ac080002",x"00ea5824",x"ac0b0002",x"00eb5027",x"ac0a0002",x"010a5023",x"ac0a0002",x"01495023",x"ac0a0002", others=>(others=>'0'));
		--signal ROM : ROM_TYPE := (x"3c011001",x"3408000d",x"ac280000",x"3408000c",x"ac280004",x"01085021",x"014a5021",x"01483821",x"ac270008",x"8c2a0004",x"8c270000",x"ac270004",x"8c270008",x"34e80001",x"00e8482a",x"00e84023",x"00ea5824",x"00eb5027",x"010a5023",x"01495023",x"ac0a0002", others=>(others=>'0'));
		-- signal ROM : ROM_TYPE := (x"3c011001",x"00000000",x"00000000",x"00000000",x"3408000d",x"00000000",x"00000000",x"00000000",x"ac280000",x"00000000",x"00000000",x"00000000",x"3408000c",x"00000000",x"00000000",x"00000000",x"ac280004",x"00000000",x"00000000",x"00000000",x"01085021",x"00000000",x"00000000",x"00000000",x"014a5021",x"00000000",x"00000000",x"00000000",x"01483821",x"00000000",x"00000000",x"00000000",x"ac270008",x"00000000",x"00000000",x"00000000",x"8c2a0004",x"00000000",x"00000000",x"00000000",x"8c270000",x"00000000",x"00000000",x"00000000",x"ac270004",x"00000000",x"00000000",x"8c270008",x"00000000",x"00000000",x"00000000",x"34e80001",x"00000000",x"00000000",x"00000000",x"00e8482a",x"00000000",x"00000000",x"00000000",x"00e84023",x"00000000",x"00000000",x"00000000",x"00ea5824",x"00000000",x"00000000",x"00000000",x"00eb5027",x"00000000",x"00000000",x"00000000",x"010a5023",x"00000000",x"00000000",x"00000000",x"01495023",x"00000000",x"00000000",x"00000000",x"ac0a0002",x"00000000",x"00000000",x"00000000", others=>(others=>'0'));
		
		-------- BADASS TEST....
		--signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"34020001",x"00000000",x"00000000",x"00000000",x"00000000",x"01084021",x"00000000",x"00000000",x"00000000",x"00c23021",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff1",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"00000000", others=>(others=>'0'));
		-- SIGH
		-- signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"34020001",x"00000000",x"00000000",x"00000000",x"00000000",x"01084021",x"00000000",x"00000000",x"00000000",x"00c23021",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff0",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"00000000", others=>(others=>'0'));
		--signal ROM : ROM_TYPE := (x"34060000",x"3405000a",x"34080003",x"34020001",x"00000000",x"01084021",x"00c23021",x"00000000",x"10c50009",x"00000000",x"00000000",x"00000000",x"00000000",x"1000fff6",x"00000000",x"00000000",x"00000000",x"00000000",x"ac080002",x"00000000", others=>(others=>'0'));
		
		
		----- FRIDAY
--		
--ori $9, $0, 0x3
--ori $8, $0, 0x3 # max count
--ori $7, $0, 0x0 # cur count
--ori $6, $0, 0x1
--
--loophere:
--	lw $7, 2($0)
--	nop
--	nop
--	nop
--	add $9, $9, $9
--	nop
--	nop
--	nop
--	add $7, $7, $6
--	beq $7, $8, end
--	nop
--	nop
--	nop
--	
--	beq $0, $0, loophere
--		
--	nop
--	nop
--	nop
--
--
--end:
--	lw $9, 2($0)
--	nop
--	nop
--	nop
--	beq $0, $0, end
	--	signal ROM : ROM_TYPE := (x"34090003",x"34080003",x"34070000",x"34060001",x"ac070002",x"00000000",x"00000000",x"00000000",x"01294821",x"00000000",x"00000000",x"00000000",x"00e63821",x"10e80007",x"00000000",x"00000000",x"00000000",x"1000fff2",x"00000000",x"00000000",x"00000000",x"ac090002",x"00000000",x"00000000",x"00000000",x"1000fffb", others=>(others=>'0'));
	-- CLEAN VERSION
	--signal ROM : ROM_TYPE := (x"34090003",x"34080003",x"34070000",x"34060001",x"ac070002",x"01294821",x"00e63821",x"10e80001",x"1000fffb",x"ac090002",x"1000fffe", others=>(others=>'0'));
	
-- Equivalent, 1 NOP
--signal ROM : ROM_TYPE := (x"34090003",x"34080003",x"34070000",x"34060001",x"ac070002",x"00000000",x"00000000",x"00000000",x"01294821",x"00000000",x"00000000",x"00000000",x"00e63821",x"00000000",x"10e80007",x"00000000",x"00000000",x"00000000",x"1000fff1",x"00000000",x"00000000",x"00000000",x"ac090002",x"00000000",x"00000000",x"00000000",x"1000fffb", others=>(others=>'0'));



-------------------------------------------------
-- MULT and other baddies
-------------------------------------------------

-- signal ROM : ROM_TYPE := (x"34090003",x"34060002",x"00000000",x"00003812",x"ac070002",x"1000fffe", others=>(others=>'0'));
-- WITH NOP, 2* 3, expect 6
--signal ROM : ROM_TYPE := (x"34090003",x"34060002",x"00000000",x"00000000",x"00000000",x"01260018",x"00000000",x"00000000",x"00000000",x"00003812",x"00000000",x"00000000",x"00000000",x"ac070002",x"1000fffe", others=>(others=>'0'));
-- WITH NOP, -1 * -2, expect 2
--signal ROM : ROM_TYPE := (x"34010001",x"34020002",x"00014823",x"00023023",x"00000000",x"00000000",x"00000000",x"01260018",x"00000000",x"00000000",x"00000000",x"00003812",x"00000000",x"00000000",x"00000000",x"ac070002",x"1000fffe", others=>(others=>'0'));
-- BIG MULT SIGNED POSITIVE
-- expect hi = 0x04c5f4b4, lo = 0x67890002
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"00000000",x"00000000",x"00000000",x"01260018",x"00000000",x"00000000",x"00000000",x"00003812",x"00000000",x"00000000",x"00000000",x"ac070002",x"1000fffe", others=>(others=>'0'));
--signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"00000000",x"00000000",x"00000000",x"01260018",x"00000000",x"00000000",x"00000000",x"00003812",x"00000000",x"00000000",x"00000000",x"00004010",x"ac070002",x"ac080003",x"1000fffd", others=>(others=>'0'));
-- same as above, no NOPS
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"01260018",x"00003812",x"00004010",x"ac070002",x"ac080003",x"1000fffd", others=>(others=>'0'));
-- same as above, one NOP
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"01260018",x"00000000",x"00003812",x"00004010",x"ac070002",x"ac080003",x"1000fffd", others=>(others=>'0'));
-- one nop in front
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"00000000",x"01260018",x"00003812",x"00004010",x"ac070002",x"ac080003",x"1000fffd", others=>(others=>'0'));

-- SUPERSCALAR
-- expect aaa80018, should see NO stall
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"01260018",x"01265021",x"014a5021",x"014a5021",x"014a5021",x"00003812",x"00004010",x"ac070002",x"ac080003",x"ac0a0002",x"1000fffc", others=>(others=>'0'));
-- expect aaa80018/2, should see only one stall
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"01260018",x"01265021",x"014a5021",x"014a5021",x"00003812",x"00004010",x"ac070002",x"ac080003",x"ac0a0002",x"1000fffc", others=>(others=>'0'));
-- expect 55550003, should see 3 stalls
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"01260018",x"01265021",x"00003812",x"00004010",x"ac070002",x"ac080003",x"ac0a0002",x"1000fffc", others=>(others=>'0'));

-- Multiply after multiply
-- expect 55550003, first mult shouldn't have a problem
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"00c60018",x"01260018",x"01265021",x"00003812",x"00004010",x"ac070002",x"ac080003",x"ac0a0002",x"1000fffc", others=>(others=>'0'));

-- xpect ffff fffc
-- signal ROM : ROM_TYPE := (x"34010001",x"34020002",x"00014823",x"00023023",x"01260018",x"00c20018",x"00003812",x"00004010",x"ac080003",x"ac070002",x"1000fffd", others=>(others=>'0'));

-- DIV TEST
-- DIVU
-- signal ROM : ROM_TYPE := (x"3c011001",x"3408dead",x"34090eaf",x"0109001b",x"00004010",x"00003812",x"ac070002",x"ac080002", others=>(others=>'0'));
-- same as above, with loop
-- 000000f, and 26c as output (looped!)
-- signal ROM : ROM_TYPE := (x"3c011001",x"3408dead",x"34090eaf",x"0109001b",x"00004010",x"00003812",x"ac070002",x"ac080002",x"00000000", x"00000000", x"08100000", others=>(others=>'0'));

-- DIV SIGNED
-- BIG NEGATIVE NUMBER
-- Expect eabb0ab, and ffffffffd as remainder.
-- signal ROM : ROM_TYPE := (x"3c011001",x"3c088ead",x"3c091eaf",x"3508dead",x"35290eaf",x"0109001a",x"00004010",x"00003812",x"ac070002",x"ac080002",x"08100000", others=>(others=>'0'));

-- DIV SIGNED, Back to back
--signal ROM : ROM_TYPE := (x"3c011001",x"3c088ead",x"3c091eaf",x"3c070055",x"3508dead",x"35290eaf",x"34e7ffff",x"0109001a",x"0107001a",x"00004010",x"00003812",x"ac070002",x"ac080003",x"08100000", others=>(others=>'0'));
-- same as above, but with 1 nop between divs
-- signal ROM : ROM_TYPE := (x"3c011001",x"3c088ead",x"3c091eaf",x"3c070055",x"3508dead",x"35290eaf",x"34e7ffff",x"0109001a",x"00000000",x"0107001a",x"00004010",x"00003812",x"ac070002",x"ac080003",x"08100000", others=>(others=>'0'));
-- signal ROM : ROM_TYPE := (x"3c011001",x"3c088ead",x"3c091eaf",x"3c070055",x"3508dead",x"35290eaf",x"34e7ffff",x"0109001a",x"00000000",x"0107001a",x"00004010",x"00003812",x"ac070002",x"ac080003",x"08100000", others=>(others=>'0'));

-- DIV FOR SUPERSALAR
-- SIMPLE ONE TO TEST IF STALL FOR MFHI
-- signal ROM : ROM_TYPE := (x"3c011001",x"3c088ead",x"3c091eaf",x"3c070055",x"3508dead",x"35290eaf",x"34e7ffff",x"0107001a",x"00004010",x"00003812",x"ac070002",x"ac080003",x"08100000", others=>(others=>'0'));
-- SUPERSCALAR WITH INSTRUCTION INSID
-- signal ROM : ROM_TYPE := (x"3c011001",x"3c088ead",x"3c091eaf",x"3c070055",x"3508dead",x"35290eaf",x"34e7ffff",x"0107001a",x"00e73821",x"00e74021",x"00e84821",x"00004010",x"00003812",x"ac070002",x"ac080003",x"ac090002",x"08100000", others=>(others=>'0'));

-- ADDI + SLTI
-- Expect 9, 137, 9, 0 (end with 0)
-- signal ROM : ROM_TYPE := (x"20087eaf",x"20090eaf",x"292a0fdd",x"292bedcc",x"0109001b",x"00004010",x"00003812",x"ac070002",x"ac080002",x"ac0a0002",x"ac0b0002", others => (others => '0'));

-- SLL, SRL, SRA
--
-- SLL 1, expect 012f3f48 and 0000001e
-- with NOPs BEFORE and AFTER shift.
-- signal ROM : ROM_TYPE := (x"3c011001",x"3c088ead",x"3c091eaf",x"3508dead",x"35290eaf", x"00000000", x"00000000",x"00084080",x"00094902", x"0109001a",x"00004010",x"00003812",x"ac070002",x"ac080003",x"08100000", others=>(others=>'0'));
-- Same as above, but only with NOPS before
--signal ROM : ROM_TYPE := (x"3c011001",x"3c088ead",x"3c091eaf",x"3508dead",x"35290eaf", x"00084080",x"00000000",x"00000000", x"00000000",x"00094902",x"0109001a",x"00004010",x"00003812",x"ac070002",x"ac080003",x"08100000", others=>(others=>'0'));
-- Same as above, but with no NOPS
-- signal ROM : ROM_TYPE := (x"3c011001",x"3c088ead",x"3c091eaf",x"3508dead",x"35290eaf", x"00084080",x"00094902",x"0109001a",x"00004010",x"00003812",x"ac070002",x"ac080003",x"08100000", others=>(others=>'0'));
-- Same as above (no nops), but we swap instructions about to cause more hazards
-- signal ROM : ROM_TYPE := (x"3c011001",x"3c088ead",x"3c091eaf",x"3508dead",x"35290eaf", x"00094902",x"00084080",x"0109001a",x"00004010",x"00003812",x"ac070002",x"ac080003",x"08100000", others=>(others=>'0'));

--- FIX LOAD USE HAZARDS due to SLTI, ADDI
-- signal ROM : ROM_TYPE := (x"3c011001",x"34051234",x"ac250000",x"34061234",x"ac260004",x"8c280004",x"ac080002", others=>(others=>'0'));
-- ^ generic test, for sw after lw
-- Test for addi after lw, expect 2235
-- signal ROM : ROM_TYPE := (x"3c011001",x"34051234",x"ac250000",x"34061235",x"ac260004",x"8c280004",x"210a1000",x"ac0a0002", others=>(others=>'0'));

-- FIX LOAD USE HAZARDS due to SLL, SRA, SRL
-- 1) SLL, expect 48d4
-- signal ROM : ROM_TYPE := (x"3c011001",x"34051234",x"ac250000",x"34061235",x"ac260004",x"8c280004",x"00085080",x"ac0a0002", others=>(others=>'0'));
---2) SRL, make sure no unnecessary stall, expect 48d WITHOUT stalls!!!
---signal ROM : ROM_TYPE := (x"3c011001",x"34051234",x"ac250000",x"34061235",x"ac260004",x"8c280004",x"00054082",x"ac080002", others=>(others=>'0'));
---3) SRA, make sure sign is pt in correctly, expect ffabc123
-- signal ROM : ROM_TYPE := (x"3c011001",x"3c05fabc",x"34a51234",x"ac250000",x"34061235",x"ac260004",x"8c280000",x"00054103",x"ac080002", others=>(others=>'0'));

-- Test SRLV, SRAL, SLLV
-- 1) SLLV, expect 86400000
-- signal ROM : ROM_TYPE := (x"3c05fcba",x"34a5f432",x"34040015",x"00853004",x"ac060002", others=>(others=>'0'));
-- 2) SRLV expect 7e5
-- signal ROM : ROM_TYPE := (x"3c05fcba",x"34a5f432",x"34040015",x"00853006",x"ac060002", others=>(others=>'0'));
-- 3) SRAV expect fffffffc
--signal ROM : ROM_TYPE := (x"3c05fcba",x"34a5f432",x"34040018",x"00853007",x"ac060002", others=>(others=>'0'));
-- SHIFT AFTER SHIFT, expect#7e5d7a1
-- signal ROM: ROM_TYPE := (x"3c05fcba",x"34a5f432",x"34040015",x"00853006",x"00c53006",x"ac060002", others=>(others=>'0'));

-- Test BGEZ 
-- 1) Test large POSITIVE number, expect non-zero result: 7CBAF432
-- signal ROM : ROM_TYPE := (x"3c057cba",x"34a5f432",x"04a10002",x"ac000002",x"08100003",x"ac050002",x"08100005", others=>(others=>'0'));
-- 2) Test negative number, expect non-zero result: 8CBAF432
-- signal ROM : ROM_TYPE := (x"3c058cba",x"34a5f432",x"04a10001",x"08100006",x"ac000002",x"08100004",x"ac050002",x"08100006", others=>(others=>'0'));
-- 3) Same as (1), but with load hazards (two stalls)
-- signal ROM : ROM_TYPE := (x"3c011001",x"3c057cba",x"34a5f432",x"ac250004",x"8c260004",x"04c10002",x"ac000002",x"08100006",x"ac060002",x"08100008", others=>(others=>'0'));

-- TEST BGEZAL (tests are in general very similar to BGEZ, except we output the linked address in res2
-- 3) same as BGEZ(3), but with additional output, expect 7CBAF432 and 00400018
-- signal ROM: ROM_TYPE := (x"3c011001",x"3c057cba",x"34a5f432",x"ac250004",x"8c260004",x"04d10003",x"ac000002",x"ac000003",x"08100006",x"ac060002",x"ac1f0003",x"08100009", others=>(others=>'0'));
-- 4) BGEZAL with data hazard, expect 7CBAF432 and 0040124c
-- signal ROM : ROM_TYPE := (x"3c011001",x"3c057cba",x"34a5f432",x"ac250004",x"8c260004",x"04d10003",x"ac000002",x"ac000003",x"08100006",x"23fe1234",x"ac1e0003",x"ac060002",x"08100009", others=>(others=>'0'));

-- TEST JR (using BGEZAL)
-- 1) Test if we can go to a register, no obvious hazards yet, expect 4321
-- signal ROM : ROM_TYPE := (x"34010001",x"04310002",x"ac050002",x"08100002",x"34054321",x"03e00008", others=>(others=>'0'));

-- TEST JAL (using JR)
-- 1) Same as test 1 of testing JR, but instead of BGEZAL, we use JAL instead
-- signal ROM : ROM_TYPE := (x"0c100003",x"ac050002",x"08100001",x"34054321",x"03e00008", others=>(others=>'0'));

-- TEST JALR 
-- 1) expect ffff feff
-- signal ROM : ROM_TYPE := (x"3c050040",x"34a5000c",x"08100006",x"00003027",x"00e64026",x"03e00008",x"34070100",x"00a0f809",x"ac080002", others=>(others=>'0'));
-- signal ROM : ROM_TYPE := (x"3c050040",x"34a5000c",x"08100006",x"00003027",x"00e64026",x"03e00008",x"34070100",x"0005a025",x"0280f809",x"ac080002", others=>(others=>'0'));

---------------------------------------------------------------------
-- SUPERSCALAR TEST --
-----
-- MULT, then DIV, expect 3, C84ffff, 55550003
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"00c60018",x"00c9001a",x"01265021",x"00003812",x"00004010",x"ac070002",x"ac080003",x"ac0a0002",x"1000fffc", others=>(others=>'0'));
-- MULT, then DIV, with 1 add inside, with data hazards, expect fffffffa, f37a00a, 98760005
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"01260018",x"00c63021",x"00c9001a",x"01265021",x"00003812",x"00004010",x"ac070002",x"ac080003",x"ac0a0002",x"1000fffc", others=>(others=>'0'));

-- test
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"01260018",x"00c63021",x"00c9001a",x"00003812",x"00004010",x"ac080003",x"ac0a0002",x"1000fffd", others=>(others=>'0'));
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"01260018",x"00c63021",x"00c9001a",x"01265021",x"00003812",x"00004010",x"ac080003",x"ac0a0002",x"1000fffd", others=>(others=>'0'));

-- uart echo opd1
-- signal ROM : ROM_TYPE := (x"8c010004",x"20010000",x"1021fffd",x"ac010002",x"08100003", others=>(others=>'0'));
-- signal ROM : ROM_TYPE := (x"8c010004",x"1020fffe",x"ac010002",x"08100002", others=>(others=>'0'));
-- ^ use this
------
-- Demo programs, if they want to see... (replicated from above...)
---------------------------------------------------------
-- STATIC programs
---------------------------------------------------------
-- The beast test, expect 59 in decimal
-- signal ROM: ROM_TYPE := (x"3c011001",x"3408000d",x"ac280000",x"3408000c",x"ac280004",x"ac080002",x"01085021",x"014a5021",x"01483821",x"ac270008",x"ac070002",x"8c2a0004",x"8c270000",x"ac270004",x"ac070002",x"8c270008",x"34e80001",x"00e8482a",x"ac090002",x"ac070002",x"ac080002",x"00e84023",x"ac080002",x"00ea5824",x"ac0b0002",x"00eb5027",x"ac0a0002",x"010a5023",x"ac0a0002",x"01495023",x"ac0a0002", others=>(others=>'0'));
-- The strange problem test, expect C00h
-- signal ROM : ROM_TYPE := (x"34090003",x"3408000a",x"34070000",x"01294821",x"20e70001",x"10e80001",x"1000fffc",x"ac090002",x"08100007", others=>(others=>'0'));
-- The part where we show that the add etc can run while mult/div is going on
-- signal ROM : ROM_TYPE := (x"3c091234",x"3c064321",x"35290001",x"34c60002",x"01260018",x"00c63021",x"00c9001a",x"01265021",x"00003812",x"00004010",x"ac080003",x"ac0a0002",x"1000fffd", others=>(others=>'0'));
-- Static Prime Number, computes primes(up to 25), multiplies them, and divides by their sum. expect 70 (decimal) and 2230928(decimal)
-- signal ROM : ROM_TYPE := (x"0810001c",x"34080004",x"34090002",x"00095025",x"340d0003",x"34020001",x"34030003",x"8c2b0000",x"01635823",x"000d6025",x"01e07824",x"01826023",x"11820005",x"01ac001a",x"00007010",x"11c00001",x"0810000b",x"340f0001",x"11e20005",x"00280820",x"ac2d0000",x"012d0019",x"00004812",x"014d5021",x"01625823",x"21ad0001",x"0561ffee",x"03e00008",x"3c011001",x"3408001a",x"ac280000",x"0c100001",x"012a001a",x"00004810",x"00005012",x"ac090002",x"ac0a0003", others=>(others=>'0'));


------ DYNAMIC PROGRAMS
-- Dynamic Prime Number
--signal ROM : ROM_TYPE := (x"0810001c",x"34080004",x"34090002",x"00095025",x"340d0003",x"34020001",x"34030003",x"8c2b0000",x"01635823",x"000d6025",x"01e07824",x"01826023",x"11820005",x"01ac001a",x"00007010",x"11c00001",x"0810000b",x"340f0001",x"11e20005",x"00280820",x"ac2d0000",x"012d0019",x"00004812",x"014d5021",x"01625823",x"21ad0001",x"0561ffee",x"03e00008",x"3c011001",x"8c080004",x"1100fffe",x"ac280000",x"0c100001",x"012a001a",x"00004810",x"00005012",x"ac090002",x"ac0a0003", others=>(others=>'0'));

-- Recurrance converge
-- signal ROM : ROM_TYPE := (x"3c1e0040",x"37de0140",x"03c0f809",x"346303e8",x"34840001",x"00a05025",x"04710061",x"00641823",x"0060082a",x"1020fffb",x"ac050002",x"ac030003",x"0810000a",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"00000000",x"8c050004",x"10a0fffe",x"ac050002",x"8c060005",x"10c0fffe",x"ac060002",x"8c070004",x"10e0fffe",x"ac070002",x"03e00008",x"00052840",x"00a72821",x"00c52807",x"03e00008", others=>(others=>'0'));

-- Factorial
-- signal ROM : ROM_TYPE := (x"34040001",x"8c050004",x"10a0fffe",x"8c060005",x"10c0fffe",x"0126582a",x"216bffff",x"05710002",x"ac040002",x"08100005",x"00850018",x"21290001",x"20a50001",x"00002012",x"03e00008", others=>(others=>'0'));
-- ^ simple
signal ROM : ROM_TYPE := (x"3c168000",x"34040001",x"8c050004",x"10a0fffe",x"8c060005",x"10c0fffe",x"0126582a",x"216bffff",x"05710005",x"ac040002",x"02c4b826",x"2af803e8",x"ac180003",x"08100006",x"00850018",x"21290001",x"20a50001",x"00002012",x"03e00008", others=>(others=>'0'));
begin

   rdata <= ROM(to_integer(unsigned(addr)));

end syn;